/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Message;
 
import java.io.Serializable;
import java.util.ArrayList;

/**
 *
 * @author workshop
 */
public class QueryMessage implements Serializable{
    // from client side
    public int queryType = 0;
    public static final int TERMINATE = 0;
    public static final int SEARCH = 1;
    public static final int TRANSFER = 2;
    public static final int UPDATE = 3;
    public static final int INSERT = 4;
    public static final int DELETE = 5;
    public static final int CONFIRM = 6;
    public static final int CANCEL = 7;
    public static final int TRANSFER_BACK = 8; 
    public static final int GENERAL_SEARCH = 9;
    public static final int GENERATE_REPOT = 10;
    
    public String tableName = null;
    public ArrayList<String> outputFields = null;
    public ArrayList<String> constraintFields = null;
    public ArrayList<String> constraintValues = null;    
    public ArrayList<Integer> constraintType = null;
    public ArrayList<String> updateFields = null;
    public ArrayList<String> updateValues = null;
    public ArrayList<Integer> updateType = null;
    public static final int STRING_TYPE = 0;
    public static final int INT_TYPE = 1;
    public static final int DATE_TYPE = 2;
    public ArrayList<Boolean> isFuzzSearch = null; // indict whether these constraint is fuzz search or not
   
    public String fileName = null;
    public long fileLength;
    
    private static final long serialVersionUID = 9019685012367757690L;
    
    // from server side
    public int queryStatus;
    public String message = null;
    public ArrayList<String> result;
    
    public QueryMessage(){
        queryType = QueryMessage.TERMINATE;
    }
    
    /* search and delete query initialize */
    public QueryMessage(int queryType,String tableName,ArrayList<String> outputFields, 
            ArrayList<String> constraintFields, ArrayList<String> constraintValues,
            ArrayList<Integer> constraintType,ArrayList<Boolean> isFuzzSearch){
        
        this.queryType = queryType;
        this.tableName = tableName;
        this.outputFields = outputFields;
        this.constraintFields = constraintFields;
        this.constraintValues = constraintValues;
        this.constraintType = constraintType;
        this.isFuzzSearch = isFuzzSearch;
    }
    
    /* update query initialize */
    public QueryMessage(int queryType,String tableName,ArrayList<String> updateFields,
            ArrayList<String> updateValues,ArrayList<Integer> updateType,
            ArrayList<String> constraintFields, ArrayList<String> constraintValues,
            ArrayList<Integer> constraintType){
        
        this.queryType = queryType;
        this.tableName = tableName;
        this.updateFields = updateFields;
        this.updateValues = updateValues;
        this.updateType = updateType;
        this.constraintFields = constraintFields;
        this.constraintValues = constraintValues;
        this.constraintType = constraintType;
        
    }
    
    /* insert query initialize */
    public QueryMessage(int queryType, String tableName,
            ArrayList<String> values, ArrayList<Integer> type) {
        this.queryType = queryType;
        this.tableName = tableName;

        this.updateValues = values;
        this.updateType = type;
    }

    // for transfer files
    public QueryMessage(int queryType,String tableName, String fileName, long fileLength){
         this.queryType = queryType;
         this.tableName = tableName;
         this.fileName = fileName;
         this.fileLength = fileLength;
    }
}
